//
//  FavoriteTableViewCell.m
//  MyProject
//
//  Created by dllo on 15/10/31.
//  Copyright (c) 2015年 蓝鸥0825. All rights reserved.
//

#import "FavoriteTableViewCell.h"
#import "UIImageView+WebCache.h"

#define WIDTH self.frame.size.width
#define HEIGHT self.frame.size.height

@implementation FavoriteTableViewCell

- (void)awakeFromNib {
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self create];
    }
    return self;
    
}


- (void)create{
    
    self.viewBlack = [[UIView alloc] init];
    [self addSubview:self.viewBlack];
    [self.viewBlack release];
    
    self.imageFavorite = [[UIImageView alloc] init];
    self.imageFavoriteTaste = [[UIImageView alloc] init];
    self.imageFavoriteTime = [[UIImageView alloc] init];
    
    [self.viewBlack addSubview:self.imageFavorite];
    [self.viewBlack addSubview:self.imageFavoriteTaste];
    [self.viewBlack addSubview:self.imageFavoriteTime];
    
    [self.imageFavorite release];
    [self.imageFavoriteTaste release];
    [self.imageFavoriteTime release];
    
//    self.imageFavorite.layer.borderWidth = 1;
//    self.imageFavoriteTaste.layer.borderWidth = 1;
//    self.imageFavoriteTime.layer.borderWidth = 1;
    
    
    self.labelFavoriteTaste = [[UILabel alloc] init];
    self.labelFavoriteTime = [[UILabel alloc] init];
    self.labelFavoriteTitle = [[UILabel alloc] init];
    
    self.labelFavoriteTaste.textColor = [UIColor redColor];
    self.labelFavoriteTime.textColor = [UIColor grayColor];
    self.labelFavoriteTitle.textColor = [UIColor blueColor];
    
    
    [self.viewBlack addSubview:self.labelFavoriteTaste];
    [self.viewBlack addSubview:self.labelFavoriteTime];
    [self.viewBlack addSubview:self.labelFavoriteTitle];
    
    [self.labelFavoriteTaste release];
    [self.labelFavoriteTime release];
    [self.labelFavoriteTitle release];
    
    self.labelFavoriteTitle.font = [UIFont systemFontOfSize:20 weight:18];
    self.labelFavoriteTitle.numberOfLines = 2;
//    self.labelFavoriteTaste.layer.borderWidth = 1;
//    self.labelFavoriteTime.layer.borderWidth = 1;
//    self.labelFavoriteTitle.layer.borderWidth = 1;
//    self.viewBlack.layer.borderWidth = 1;
    
}

- (void)layoutSubviews{
    
    self.viewBlack.frame = CGRectMake(WIDTH / 100, HEIGHT / 100 , WIDTH / 100 * 98, HEIGHT / 100 * 98);
    self.imageFavorite.frame = CGRectMake(WIDTH / 100 * 2, HEIGHT / 100 * 6, WIDTH / 100 * 30, HEIGHT / 100 * 86);
    self.labelFavoriteTitle.frame = CGRectMake(WIDTH / 100 * 34, HEIGHT / 100 * 6, WIDTH / 100 * 60 , HEIGHT / 100 * 40);
    self.imageFavoriteTime.frame = CGRectMake(WIDTH / 100 * 34, HEIGHT / 100 * 50, WIDTH / 100 * 8, HEIGHT / 100 * 18);
    self.imageFavoriteTaste.frame = CGRectMake(WIDTH / 100 * 34, HEIGHT / 100 * 70, WIDTH / 100 * 8, HEIGHT / 100 * 18);
    self.labelFavoriteTime.frame = CGRectMake(WIDTH / 100 * 44, HEIGHT / 100 * 50, WIDTH / 100 * 50, HEIGHT / 100 * 20);
    self.labelFavoriteTaste.frame = CGRectMake(WIDTH / 100 * 44, HEIGHT / 100 * 70, WIDTH / 100 * 50, HEIGHT / 100 *20);
    
}



- (void)setModel:(ActivityModel *)model{
    
    if (_model != model) {
        [_model release];
        _model = [model retain];
    }
    NSLog(@"%@", model.img.class);
    
    self.imageFavorite.image = [UIImage imageNamed:@"shoucang.png"];
    self.labelFavoriteTitle.text = model.smalltext;
    self.labelFavoriteTime.text = model.period;
    self.labelFavoriteTaste.text = model.end_date;
    
}



@end
